package com.appspot.smartgan.util;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang3.StringEscapeUtils;

import android.graphics.Bitmap;

@SuppressWarnings("serial")
public class Message implements Comparable<Message>, Serializable {
	
	private String title;
	private String message;
	private Date date;
	
	// "optional"
	private boolean toTeacher;
	private String imageUrl;
	private Bitmap imageBitmap;
	
	
	public Message(String title, String message, Date date) {
		this.title = StringEscapeUtils.unescapeJava(title);
		this.message = StringEscapeUtils.unescapeJava(message);
		this.date = date;
		
		this.toTeacher = false;
		this.imageUrl = null;
		this.imageBitmap = null;
	}
	
	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	public boolean isToTeacher() {
		return toTeacher;
	}

	public void setToTeacher(boolean toTeacher) {
		this.toTeacher = toTeacher;
	}

	/**
	 * @return the imageUrl
	 */
	public String getImageUrl() {
		return imageUrl;
	}

	/**
	 * @param imageUrl the imageUrl to set
	 */
	public void setImageUrl(String imageUrl) {
		if (!imageUrl.equals("null")) {
			this.imageUrl = imageUrl;
		}
	}

	public Bitmap getImageBitmap() {
		return imageBitmap;
	}

	public void setImageBitmap(Bitmap imageBitmap) {
		this.imageBitmap = imageBitmap;
	}
	
	public void setMessage(String message) {
		this.message = message;
	}

	@Override
	public int compareTo(Message another) {
		return date.compareTo(another.date);
	}
}
